import { createRouter, createWebHistory } from "vue-router";
import HomeView from "@/views/home.vue";

import { useTitle } from "@vueuse/core";

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: "/",
      name: "home",
      component: HomeView,
      meta: {
        title: "首页",
      },
    },
  ],
});

router.beforeEach((to, _, next) => {
  const title = `${to?.meta?.title} - ${import.meta.env.VITE_GLOB_APP_TITLE}`;
  useTitle(title as string);
  next();
});

export default router;
